<#assign menu="events">
<#assign submenu="events_list">
<#include "/system/head.ftl">
<style type="text/css">
    .pagination {
        border-radius: 4px;
        display: inline-block;
        margin: 0;
        padding-left: 0;
    }
    table tr{
        text-align: center;
    }

    th{
        text-align: center;
    }
</style>
<!--main content start-->
<section id="main-content">
    <section class="wrapper">
        <!-- page start-->
        <section class="panel">
            <div class="tab-content">
                <div class="portlet box blue">

                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-gift"></i>社区管理
                        </div>

                        <div class="actions">
                            <a href="${basePath}/admin/events/add.htm" class="btn btn-default btn-sm">
                                <i class="fa fa-pencil"></i> 添加 </a>
                        </div>
                    </div>

                    <div class="portlet-body">

                        <div class="row">

                            <form method="post" action="${basePath}/admin/events/search.htm" class="form-horizontal" role="form">

                                <div class="col-md-10 form-group">
                                    <div class="col-md-3">
                                        <label class="col-md-4 control-label" style="font-size: 16px;">活动类型</label>
                                        <div class="col-md-8">
                                            <select name="interestId" id="interest-select"
                                                    class="selectpicker show-tick dropup form-control">
                                            <#list interestList as e>
                                                <option value=${e.id}>${e.name}</option>
                                            </#list>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-md-3">
                                        <label class="col-md-4 control-label" style="font-size: 16px;">职业类型</label>
                                        <div class="col-md-8">
                                            <select name="professionId" id="profession-select"
                                                    class="selectpicker show-tick dropup form-control">
                                            <#list professionList as e>
                                                <option value=${e.id}>${e.name}</option>
                                            </#list>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-md-3">
                                        <label class="col-md-4 control-label" style="font-size: 16px;">推送组</label>
                                        <div class="col-md-8">
                                            <select name="pushId" id="push-select"
                                                    class="selectpicker show-tick dropup form-control">
                                            <#list pushList as e>
                                                <option value=${e.id}>${e.name}</option>
                                            </#list>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-md-3">
                                        <label class="col-md-4 control-label" style="font-size: 16px;">地址</label>

                                        <div class="input-group col-md-8">
                                            <input type="text" class="form-control" name="createAddress" id="createAddress">
                                        </div>


                                    </div>
                                </div>

                                <div class="col-md-2 form-group">
                                    <label class="col-md-2">

                                    </label>
                                    <button id="events_find" class="btn btn-success blue" type="submit"
                                            ><i class="fa fa-arrow-left fa-fw"></i>
                                        查找
                                    </button>
                                </div>
                            </form>

                        </div>

                        <div class="panel-body">
                            <div class="adv-table">
                                <div role="grid" class="dataTables_wrapper" id="hidden-table-info_wrapper">
                                    <table class="table table-striped table-advance table-hover">
                                        <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>活动图片</th>
                                            <th>活动title</th>
                                            <th>活动地址</th>
                                            <th>活动描述</th>
                                            <th>活动类型</th>
                                            <th>推送组</th>
                                            <th>状态</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody role="alert" aria-live="polite" aria-relevant="all">
                                        <#list pageVo.list as e>
                                        <tr class="gradeA odd">
                                            <td>${e.id}</td>
                                            <td>
                                                <#list e.imageList! as i>
                                                    <img src="${i.path}" width="50px" height="50px"/>
                                                </#list>
                                            </td>
                                            <td>${e.name!}</td>
                                            <td>${e.createAddress!}</td>
                                            <td>${e.description!}</td>
                                            <td>${e.interests!}</td>
                                            <td>${e.push!}</td>
                                            <td>
                                                <#if e.available==1>
                                                    <span class="label label-sm label-success">在用</span>
                                                </#if>
                                                <#if e.available==0>
                                                    <span class="label label-sm label-default">禁用</span>
                                                </#if>
                                            </td>
                                            <td>

                                                <a href="${basePath}/admin/events/edit.htm?eventsId=${e.id}" title="修改"
                                                   class="btn btn-sm blue">
                                                    编辑
                                                </a>

                                                <#if e.available==1>
                                                    <a class="js_delete_events btn btn-sm blue"
                                                       href="javascript:void(0);" eventsId="${e.id}"
                                                       title="禁用">
                                                        禁用
                                                    </a>


                                                </#if>

                                            </td>

                                        </tr>
                                        </#list>
                                        </tbody>
                                    </table>
                                    <div style="height: 30px;">
                                        <div class="pagination">${pageVo.pageNumHtml} </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </section>
        <!-- page end-->
    </section>
</section>
<!--main content end-->
<script>

    $(function () {
        var pageNum = "${p}";
        $('.js_delete_events').click(function () {
            var eventsId = $(this).attr('eventsId');
            bootbox.dialog({
                message: "是否" + $(this).attr('title'),
                title: "提示",
                buttons: {
                    "delete": {
                        label: "确定",
                        className: "btn-success",
                        callback: function () {
                            $.get("${basePath}/admin/events/takeOff.json", {"eventsId": eventsId}, function (data) {
                                window.location.reload();
                            });
                        }
                    },
                    "cancel": {
                        label: "取消",
                        className: "btn-primary",
                        callback: function () {

                        }
                    }
                }
            });
        });

        $('.js_getOn_events').click(function () {
            var eventsId = $(this).attr('eventsId');
            bootbox.dialog({
                message: "是否" + $(this).attr('title'),
                title: "提示",
                buttons: {
                    "getOn": {
                        label: "确认",
                        className: "btn-success",
                        callback: function () {
                            $.get("${basePath}/admin/events/getOn.json", {"eventsId": eventsId}, function (data) {
                                window.location.reload();
                            })
                        }
                    },
                    "cancel": {
                        label: "取消",
                        className: "btn-primary",
                        callback: funtion()

                    }
                }
            })
        })


        $(".js_appUser_check").change(function () {
            $.post("${basePath}/manage/appUser/check.json",
                    {"articleId": $(this).attr("appUserId"), check: $(this).val()},
                    function (data) {
                        if (data.result) {
                            window.location.href = "${basePath}/manage/appUser/list.htm?p=" + pageNum;
                        } else {
                            bootbox.alert(data.msg,
                                    function () {
                                        window.location.href = "${basePath}/manage/appUser/list.htm?p=" + pageNum;
                                    });
                        }
                    }, "json");
        });


        $("#push-select").val("${pushId!''}");
        $("#interest-select").val("${interestId!''}");
        $("#createAddress").val("${createAddress!''}");
        $("#profession-select").val("${professionId!''}");
    })

</script>
<#include "/system/foot.ftl">
